﻿using Furion;
using Furion.DynamicApiController;
using YFurion.DataFilters;
using YFurion.Localization;
using YFurion.Session;

namespace YFurion.Controllers
{
    public abstract class YController : IDynamicApiController
    {
        protected IDataFilter DataFilter { get; }
        protected IYSession YSession { get; }
        protected ILocalizationManager LocalizationManager { get; }
        protected string LocalizationAssemblyName { get; set; } = LocalizationConst.LocalizationAssemblyName;
        protected string LocalizationManagerNameSuffix { get; set; } = LocalizationConst.LocalizationManagerNameSuffix;

        public YController()
        {
            DataFilter = App.GetService<IDataFilter>();
            YSession = App.GetService<IYSession>();
            LocalizationManager = App.GetService<ILocalizationManager>();
        }

        /// <summary>
        /// 获取语言
        /// </summary>
        /// <param name="name">名称</param>
        /// <returns></returns>
        protected string L(string name)
        {
            return LocalizationManager.GetString(name, LocalizationAssemblyName, LocalizationManagerNameSuffix);
        }
    }
}
